/************************************************************************
This file is part of Polar4linux
Copyright (C) 2010-2011 Eric jrdn2
Portions Copyright (C) 2007 Matti Juvonen <mpj@iki.fi> (RS400 Tools)
Portions Copyright (C) 2006 Jani Hursti <jani.hursti@hut.fi>,
Portions Copyright (C) 2001-2003 Tom Oliveira e Silva

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
************************************************************************/

#ifndef _POLARCALENDAR_H
#define _POLARCALENDAR_H

#include <QFile>
#include <QDate>
#include <QMenu>
#include <QPushButton>
#include <QGraphicsProxyWidget>
#include <QGraphicsView>
#include <QGraphicsTextItem>
#include <sys/stat.h>
#include <iostream>
#include <math.h>

#include "polarSubs.h"
#include "polarSessionView.h"

class SimpleItem;

class polarCalendar:public QGraphicsView
{
Q_OBJECT

public:
	polarCalendar(QWidget *parent = 0);
	void plotCalendar();
	void deselectItem(SimpleItem* itm);
	void selectItem(SimpleItem* itm);
	void showPreview();
	void invalidatePreview();
	void askForExerciseDisplay(QPointF &pt);
	void mousePressEvent(QMouseEvent *event);
	void mouseMoveEvent ( QMouseEvent * event );
	void resizeEvent ( QResizeEvent * event );
	void drawBackground ( QPainter * painter, const QRectF & rect );
	
	QDate firstDate;

	polar4linuxInternals *internals;
	void initialize(polar4linuxInternals *internals0);
	
	//for plots
	QDate selectedDate;
	
	int selectedExercise;
	QGraphicsPixmapItem *previewitm;
	static const int cellsize =40;

signals:
	void newdate(QDate thedate,int exnum, int method);
	void newdatePrev(QDate thedate,int exnum);//preview
	void newSummary(QDate thedate); //week summary
	
private slots:
	void redraw();
	void triggerNewDate();
	void triggerWeekSum();
	void triggerDeleteExercise();
	
private:
	SimpleItem* selection;

	QPen gPen;
	QBrush gBrush;
};

#endif


